import homeApi from './home'
import loginApi from './login'
import spreadJs from './spreadJs'
let apiArr = [homeApi, loginApi, spreadJs]

export default (function () {
  let data = arguments[0]
  let keyArr = []
  let obj = {}
  for (let i = 0; i < data.length; i++) {
    if (Object.prototype.toString.call(data[i]) !== '[object Object]') {
      console.log('数组中存在非对象')
      return obj
    }
    for (let k in data[i]) {
      keyArr.push(k)
    }
  }
  // 判断是否有重复数据
  let newArr = []
  let reArr = []
  for (let j = 0; j < keyArr.length; j++) {
    if (newArr.indexOf(keyArr[j]) === -1) {
      newArr.push(keyArr[j])
    } else {
      reArr.push(keyArr[j])
    }
  }
  if (reArr.length) {
    console.log(reArr + '方法重复')
    return obj
  }

  for (let j = 0; j < data.length; j++) {
    Object.assign(obj, data[j])
  }
  return obj
})(apiArr)
